home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1996 February
/
EnigmA AMIGA RUN 04 (1996)(G.R. Edizioni)(IT)[!][issue 1996-02][Skylink CD III].iso
/
earcd
/
midi
/
gfft.lha
/
gfft-2.03
/
source
/
gfft-2.03-source.lha
/
wbenchm.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-01-02
|
5KB
|
227 lines
/***************************************************************************
* Copyright (C) 1994 Charles P. Peterson *
* 4007 Enchanted Sun, San Antonio, Texas 78244-1254 *
* Email: Charles_P_Peterson@fcircus.sat.tx.us *
* *
* This is free software with NO WARRANTY. *
* See gfft.c, or run program itself, for details. *
* Support is available for a fee. *
***************************************************************************
*
* Program: gfft--General FFT analysis
* File: wbenchm.c
* Purpose: workbench GUI main functions
* Author: Charles Peterson (CPP)
* History: 19-Nov-1993 CPP; Created.
* 19-Jan-1995 CPP; (1.22) Make GFFT shell bigger & go away
* 20-Jan-1995 CPP; (1.23) Use Icon Tooltypes
* Comments: Workbench GUI. Amiga Dependent!
*/
#ifdef AMIGA
#include <stdlib.h> /* exit() */
#include <stdio.h> /* sprintf() */
#include <string.h>
/*
* Amiga includes
*/
#include <exec/types.h>
#include <exec/exec.h>
#include <workbench/workbench.h>
#include <workbench/icon.h>
#include <workbench/startup.h>
#include <intuition/intuition.h>
#include <clib/intuition_protos.h>
#include <clib/exec_protos.h>
#include <proto/icon.h>
#include <proto/dos.h>
#include <dos/dos.h>
/*
* GFFT includes
*/
#include "gfft.h"
#include "settings.h" /* for testing */
#include "wbench.h"
/*
* Default console (Many thanks to SAS for making this possible.)
*/
char __stdiowin[] = "CON:0/000/640/200/GfftConsole";
char __stdiov37[]= "/AUTO/CLOSE";
extern struct WBStartup *WBenchMsg;
/*
* Semi-static variables (used also by wbdialog)
*/
LONG num_files = 0;
LONG file_index = 0;
int Tooltype_Errors = 0;
extern BOOLEAN Tooltype_Errors_Reported;
/*
* Statics
*/
static int within_workbench_loop = FALSE;
static void workbench_dialog_loop (void);
static void process_tooltypes (UBYTE *name);
void workbench_main (void)
{
LONG olddir;
open_libraries ();
/*
* Process GFFT.info tooltypes, if any
*/
if (WBenchMsg && WBenchMsg->sm_NumArgs && WBenchMsg->sm_ArgList)
{
struct WBArg *wbarg = WBenchMsg->sm_ArgList;
olddir = CurrentDir (wbarg->wa_Lock);
process_tooltypes (wbarg->wa_Name);
CurrentDir (olddir);
}
Tooltype_Errors = Error_Count;
/*
* Process project icons/files, if any
*/
if (WBenchMsg && (num_files = WBenchMsg->sm_NumArgs - 1))
{
/*
* Loop through selected project icon(s)
*/
for (file_index = 0; file_index < num_files; file_index++)
{
/*
* Change to directory containing selected object (file)
* then, open it
* then, change back
* then, run dialog window
* (if error, try next file)
*/
LONG i = file_index;
CATCH_ERROR
{
olddir = CurrentDir (WBenchMsg->sm_ArgList[i+1].wa_Lock);
set_read (WBenchMsg->sm_ArgList[i+1].wa_Name);
process_tooltypes (WBenchMsg->sm_ArgList[i+1].wa_Name);
CurrentDir (olddir);
workbench_dialog_loop ();
}
END_CATCH_ERROR;
}
}
else
{
/*
* No project files selected
*/
CATCH_ERROR
{
workbench_dialog_loop ();
}
END_CATCH_ERROR;
}
}
/*
* The following functions permit the CLI interactive mode to be activated
* from the workbench, and the CLI to be started from the workbench, and
* to return the the original mode.
*/
static void workbench_dialog_loop (void)
{
int next_action = WORKBENCH_MODE;
BOOLEAN help_displayed = FALSE;
within_workbench_loop = TRUE;
Plot = ANY_PLOT;
while (next_action == WORKBENCH_MODE ||
next_action == INTERACTIVE_MODE)
{
switch (next_action)
{
case WORKBENCH_MODE:
next_action = workbench_dialog ();
break;
case INTERACTIVE_MODE:
if (!help_displayed)
{
printf ("This is the GFFT CLI-interactive interface...\n");
printf ("Enter WORKBENCH to return to dialog window.\n");
printf ("Enter QUIT to quit without returning to dialog window.\n");
printf ("Enter HELP to see a complete list of commands.\n");
help_displayed = TRUE;
}
cli_interactive_loop (FALSE);
next_action = WORKBENCH_MODE;
break;
}
}
within_workbench_loop = FALSE;
}
char *workbench_command (char *arguments)
{
int previous_command_mode = CommandMode;
if (within_workbench_loop)
{
CommandMode = WORKBENCH_MODE;
return arguments;
/*
* return to workbench through cli_interactive_loop
*/
}
else
{
workbench_dialog_loop ();
CommandMode = previous_command_mode;
}
return arguments;
}
static void process_tooltypes (UBYTE *name)
{
int starting_error_count = Error_Count;
struct DiskObject *disk_obp;
if (disk_obp = GetDiskObject (name))
{
int i;
char *tool;
int previous_command_mode = CommandMode;
CommandMode = BATCH_MODE;
for (i = 0; tool = disk_obp->do_ToolTypes[i]; i++)
{
if (!ignore_tooltype (tool))
{
execute_command_line (tool, NULL);
}
}
CommandMode = previous_command_mode;
}
if (Error_Count > starting_error_count)
{
Tooltype_Errors += Error_Count - starting_error_count;
Tooltype_Errors_Reported = FALSE;
}
}
#endif /* ifdef AMIGA */